<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('订单主子表提交修改界面')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form id="form-edit" class="form-horizontal">
            <h4 class="form-header h4">订购单信息</h4>
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">订单编号：</label>
                        <div class="col-sm-8">
                            <input name="orderIndent" id="orderIndent" class="form-control" th:value="${order2.orderIndent}" type="text" maxlength="30" readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">客户姓名：</label>
                        <div class="col-sm-8" >
                            <input name="customerName" disabled th:value="${order2.customerName}" class="form-control" type="text" maxlength="30">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">订购时间：</label>
                        <div class="col-sm-8">
                            <div class="input-group date">
                                <input name="orderTime" disabled class="form-control" placeholder="yyyy-MM-dd hh:mm:ss" readonly type="text" th:value="${#dates.format(order2.orderTime, 'yyyy-MM-dd hh:mm:ss')}">
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">创建人：</label>
                        <div class="col-sm-8">
                            <input name="sysOperUserId" disabled class="form-control" type="hidden"  th:value="${user.userId}">
                            <input name="" class="form-control" disabled type="text" readonly  th:value="${user.userName}">
                        </div>
                    </div>

                <div class="form-group">
                        <label class="col-sm-4 control-label is-required">总金额：</label>
                        <div class="col-sm-8">
                            <input id="orderMoney" name="orderMoney" th:value="${order2.orderMoney}" class="form-control" type="text" maxlength="11" disabled>
                        </div>
                 </div>

            <div class="form-group">
                <label class="col-sm-4 control-label is-required">审核意见：</label>
                <div class="col-sm-8" >
                    <textarea name="opinion" value="" class="form-control" type="text" maxlength="30"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-4 control-label" is-required>审核状态：</label>
                <div class="col-sm-8">
                    <select name="chkStatus"   class="form-control " data-first-title="请选择">
                        <option value="">请选择</option>
                        <option value="2">通过</option>
                        <option value="3">不通过</option>
                    </select>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="col-sm-12 select-table table-striped" >
					    <table id="bootstrap-table"  >
                        </table>
					</div>
                </div>
            </div>


        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:src="@{/js/jquery.tmpl.js}"></script>
	<script th:inline="javascript">

        $(function() {
            let data1 ='[[${poProduct2List}]]'.replace(/^\"|\"$/g,'');
            console.log('[[${poProduct2List}]]');
            console.log(typeof data1);
            console.log("parseJSON:"+jQuery.parseJSON(data1));
            var options = {
                data: jQuery.parseJSON(data1),
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'index',
                        align: 'center',
                        title: "序号",
                        formatter: function (value, row, index) {
                            var columnIndex = $.common.sprintf("<input type='hidden' disabled name='index' value='%s'>", $.table.serialNumber(index));
                            var columnId = $.common.sprintf("<input type='hidden' disabled name='' id='mkOrderIndent' value='%s'>", index, row.id);
                            return columnIndex + $.table.serialNumber(index) + columnId;
                        }
                    },
                    {
                        field: 'poBrandId',
                        align: 'center',
                        title: '品牌',
                        formatter: function(value, row, index) {
                            var data = [{ index: index, poBrandId: value }];
                            return $("#goodsTypeTpl1").tmpl(data).html();
                        }
                    },
                    {
                        field: 'poTypeId',
                        align: 'center',
                        title: '类型',
                        formatter: function(value, row, index) {
                            var data = [{ index: index, poTypeId: value }];
                            return $("#goodsTypeTpl2").tmpl(data).html();
                        }
                    },
                    {
                        field: 'productModel',
                        align: 'center',
                        title: '型号',
                        formatter: function(value, row, index) {
                            var data = [{ index: index, productModel: value }];
                            return $("#goodsTypeTpl3").tmpl(data).html();
                        }
                    },
                    {
                        field: 'num',
                        align: 'center',
                        title: '数量',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' disabled type='text' id='num' name='poProduct2List[%s].num' value='%s'>", index, value);
                            return html;
                        }
                    },
                    {
                        field: 'unit',
                        align: 'center',
                        title: '单位',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' disabled type='text' name='poProduct2List[%s].unit' value='台' >", index, value);
                            return html;
                        }
                    },
                    {
                        field: 'price',
                        align: 'center',
                        title: '商品价格',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control price' disabled type='text' id='price'  name='poProduct2List[%s].price' value='%s'>", index, value);
                            return html;
                        }
                    },
                    {
                        field: 'total',
                        align: 'center',
                        title: '金额',
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control money' disabled type='text' readonly id='money' name='poProduct2List[%s].total' value='%s'>", index, value);
                            return html;
                        }
                    },
                    {
                    field: 'detailId',
                    align: 'center',
                    // title: '订单详情id',
                    formatter: function (value, row, index) {
                    var html = $.common.sprintf("<input class='form-control money' type='hidden' disabled id='detailId' name='poProduct2List[%s].detailId' value='%s'>", index, value);
                    return html;
            }}
        ]
            };
            $.table.init(options);
        });


        var prefix = ctx + "market/check"
        $("#form-edit").validate({
            focusCleanup: true
        });


        function submitHandler() {
            if ($.validate.form()) {
                // alert($('#form-edit').serialize());
                $.operate.save(prefix + "/edit", $('#form-edit').serialize());
            }
        }

        function addColumn() {
        	var row = {
                poBrandId: "",
                poTypeId: "",
                productModel: "",
                num: "",
                unit: "",
                price: "",
                total: "",
                detailId:""
            }
        	sub.addColumn(row);
        }


    </script>

</body>
</html>
<!-- 品牌 -->
<script id="goodsTypeTpl1" type="text/x-jquery-tmpl">
<div th:each="p : ${poProductList}">
<input class='form-control' disabled type='text' th:if='${p.poBrandId}==3'  name='poProduct2List[${index}].poBrandId' value='海尔1'>
<input class='form-control' disabled type='text' th:if='${p.poBrandId}==4'  name='poProduct2List[${index}].poBrandId' value='联想'>
<input class='form-control' disabled type='text' th:if='${p.poBrandId}==11' name='poProduct2List[${index}].poBrandId' value='联想1'>
</div>
</script>

<!-- 类型 -->
<script id="goodsTypeTpl2" type="text/x-jquery-tmpl">
<div th:each="p : ${poProductList}">
<input class='form-control' disabled type='text' th:if='${p.poTypeId}==1'  name='poProduct2List[${index}].poTypeId' value='笔记本电脑'>
<input class='form-control' disabled  type='text' th:if='${p.poTypeId}==2'  name='poProduct2List[${index}].poTypeId' value='笔记本电脑'>
<input class='form-control' disabled type='text' th:if='${p.poTypeId}==3' name='poProduct2List[${index}].poTypeId' value='笔记本电脑'>
</div>
</script>
<!-- 型号 -->
<script id="goodsTypeTpl3" type="text/x-jquery-tmpl">
<div th:each="p : ${poProductList}">
<input class='form-control'disabled type='text' th:if="${p.productModel} eq '苹果13'"  name='poProduct2List[${index}].poTypeId' value='苹果13'>
<input class='form-control' disabled type='text' th:if="${p.productModel} eq '拯救者y7000'"  name='poProduct2List[${index}].poTypeId' value='拯救者y7000'>
<input class='form-control' disabled type='text' th:if="${p.productModel} eq '小米144寸臻享版平板'" name='poProduct2List[${index}].poTypeId' value='小米144寸臻享版平板'>
</div>
</script>